package main

import "fmt"

func main() {
	/*// 创建集合
	var countryCapitalMap map[string]string
	countryCapitalMap = make(map[string]string)
	// map插入key-value对，各个国家对应的首都
	countryCapitalMap["France"] = "巴黎"
	countryCapitalMap["Italy"] = "罗马"
	countryCapitalMap["Japan"] = "东京"
	countryCapitalMap["India"] = "新德里"
	// 使用键输出地图值
	for country := range countryCapitalMap {
		fmt.Println(country, "首都是", countryCapitalMap[country])
	}
	// 查看元素在集合中是否存在
	capital, ok := countryCapitalMap["American"]
	if (ok) {
		fmt.Println("American的首都是", capital)
	} else {
		fmt.Println("American的首都不存在")
	}*/

	// 创建map
	countryCapitalMap := map[string]string{"France": "Paris", "Italy": "Rome", "Japan": "Tokyo", "India": "New delhi"}
	fmt.Println("原始地图")
	// 打印地图
	for country := range countryCapitalMap {
		fmt.Println(country, "首都是", countryCapitalMap[country])
	}
	// 删除元素
	delete(countryCapitalMap, "France")
	fmt.Println("法国条目被删除")
	fmt.Println("删除元素后地图")
	// 打印地图
	for country := range countryCapitalMap {
		fmt.Println(country, "首都是" ,countryCapitalMap[country])
	}
}
